home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
201-225
/
disk_218
/
edlib
/
filetype.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
844b
|
46 lines
/*
* edlib v1.1 Copyright 1989 Edwin Hoogerbeets
* This code is freely redistributable as long as no charge other than
* reasonable copying fees are levied for it.
*/
#include "edlib.h"
#include <libraries/dos.h>
#include <exec/memory.h>
#include <errno.h>
#define FIBSIZE sizeof(struct FileInfoBlock)
extern struct FileInfoBlock *AllocMem();
extern struct FileLock *Lock();
int filetype(path)
char *path;
{
register struct FileInfoBlock *fib;
register struct FileLock *lock;
register int result;
if ( !(fib = AllocMem(FIBSIZE,MEMF_CLEAR)) ) {
errno = ENOMEM;
return(-1);
}
if ( !(lock = Lock(path,ACCESS_READ)) ) {
errno = EACCES;
return(-1);
}
Examine(lock,fib);
result = ( fib->fib_DirEntryType > 0 ) ? TYPE_DIR : TYPE_FILE;
UnLock(lock);
FreeMem(fib,FIBSIZE);
return(result);
}